<f:view xmlns="http://www.w3.org/1999/xhtml" 
	xmlns:aui="http://liferay.com/faces/aui"
	xmlns:c="http://java.sun.com/jsp/jstl/core" 
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html" 
	xmlns:bridge="http://liferay.com/faces/bridge"
	xmlns:p="http://primefaces.org/ui" 
	xmlns:example-cc="http://java.sun.com/jsf/composite/example-cc"
	xmlns:ui="http://java.sun.com/jsf/facelets">
	
	<h:head />
	<h:body>
		<h:form id="appointmentListForm">
		    <p:dataTable id="appointmentTable" styleClass="electroOfficeTable"
		    			 var="aWrapper" value="#{appointmentListController.appointments}"
		    			 selection="#{appointmentListController.selectedAppointment}"
		    			 selectionMode="single"
		   				 rowKey="#{aWrapper.appointment.id}"
		                 paginator="true" rows="10"
		                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
		                 rowsPerPageTemplate="5,10,15,25,50"  
		                 filteredValue="#{appointmentListController.filteredAppointments}"
		                 widgetVar="appointmentListWidget"
		                 emptyMessage="Keine Aufträge gefunden"
		                 currentPageReportTemplate="Seite {currentPage} von {totalPages}" >
				
				<p:ajax event="rowSelect" update=":appointmentListForm" />
					
		        <f:facet id="headerFacet" name="header" styleClass="headerFacet" >
		        	<p:menubar styleClass="menubar" >
				        <p:submenu label="Datei" icon="ui-icon-document">
				            <p:submenu label="Neu" icon="ui-icon-contact">
				                <p:menuitem value="Auftrag" url="#" />
				                <p:menuitem value="Messprotokoll"
			        					actionListener="#{appointmentListController.navigateToMeasurementEdit}"
			        					disabled="#{!appointmentListController.oneAppointmentSelected}" 
			        					ajax="false"
										immediate="true" />
				            </p:submenu>
				            <p:separator />
				            <p:menuitem value="Auftragsdetails" 
			        				actionListener="#{appointmentListController.navigateToAppointmentView}"
			        				disabled="#{!appointmentListController.oneAppointmentSelected}"
			        				ajax="false"
									immediate="true" />
							<p:separator />
							<p:menuitem value="PDF erstellen"
			        					actionListener="#{appointmentListController.navigateToPdfReader}"
			        					disabled="#{!appointmentListController.oneAppointmentSelected}"
			        					ajax="false"
										immediate="true" />
							<p:separator />
							<p:menuitem value="Seite Drucken" url="#" />
							<p:separator />
							<p:menuitem value="Import" url="#" />
							<p:menuitem value="Export" url="#" />
				        </p:submenu>
				 
				        <p:submenu label="Bearbeiten" icon="ui-icon-pencil">
				            <p:menuitem value="Auftrag bearbeiten" 
			        				actionListener="#{appointmentListController.navigateToAppointmentEdit}"
			        				disabled="#{!appointmentListController.oneAppointmentSelected}"
			        				ajax="false"
									immediate="true" icon="ui-icon-arrowreturnthick-1-w" />
							<p:menuitem value="Auftrag abschliessen"
			        				actionListener="#{appointmentListController.closeAppointment}"
			        				disabled="#{!appointmentListController.oneAppointmentSelected}"
			        				rendered="#{aWrapper.appointment.state.name eq Offen}"
			        				ajax="false"
									immediate="true" />
							<p:menuitem value="Auftrag erneut öffnen"
			        				actionListener="#{appointmentListController.openAppointment}"
			        				disabled="#{!appointmentListController.oneAppointmentSelected}"
			        				rendered="#{aWrapper.appointment.state.name eq Geschlossen}"
			        				ajax="false"
									immediate="true" />
				        </p:submenu>
				 
				        <f:facet name="options">
				            <p:inputText id="globalFilter" onkeyup="appointmentListWidget.filter()" placeholder="Suche" style="width:150px" />
				        </f:facet>
				    </p:menubar>
		        </f:facet>
				
	        	<p:column headerText="Rapport-Nr." width="80px" 
	        			sortBy="#{aWrapper.appointment.reportNumber}" 
	        			filterBy="#{aWrapper.appointment.reportNumber}"
	        			filterMatchMode="contains" 
	        			id="reportNumber" >
	        		<h:outputText value="#{aWrapper.appointment.reportNumber}" />
		        </p:column>
				<p:column headerText="Projekt-Nr." width="80px"
	        			sortBy="#{aWrapper.appointment.projectNumber}" 
	        			filterBy="#{aWrapper.appointment.projectNumber}"
	        			filterMatchMode="contains" 
	        			id="projectNumber" >
	        		<h:outputText value="#{aWrapper.appointment.projectNumber}" />
		        </p:column>
		        <p:column headerText="Vorname" 
	        			sortBy="#{aWrapper.customerAddress.firstname}" 
	        			filterBy="#{aWrapper.customerAddress.firstname}"
	        			filterMatchMode="contains" 
	        			id="firstname" >
	        		<h:outputText value="#{aWrapper.customerAddress.firstname}" />
		        </p:column>
		        <p:column headerText="Nachname" 
	        			sortBy="#{aWrapper.customerAddress.lastname}" 
	        			filterBy="#{aWrapper.customerAddress.lastname}"
	        			filterMatchMode="contains" 
	        			id="lastname" >
	        		<h:outputText value="#{aWrapper.customerAddress.lastname}" />
		        </p:column>
		        <p:column headerText="Auftrag"
	        			sortBy="#{aWrapper.appointment.subject}" 
	        			filterBy="#{aWrapper.appointment.subject}"
	        			filterMatchMode="contains" 
	        			id="subject" >
	        		<h:outputText value="#{aWrapper.appointment.subject}" />
		        </p:column>
		        <p:column headerText="Auftragsdatum" 
	        			sortBy="#{aWrapper.appointment.appointmentDate}" 
	        			filterBy="#{aWrapper.appointment.appointmentDate}"
	        			filterMatchMode="contains" 
	        			id="appointmentDate" >
        			<h:outputText value="#{aWrapper.appointment.appointmentDate}" >
        				<f:converter converterId="LocalDateTimeConverter" />
        			</h:outputText>
		        </p:column>
		        <p:column headerText="Zuständig" width="100px"
	        			sortBy="#{aWrapper.user.fullName}" 
	        			filterBy="#{aWrapper.user.fullName}"
	        			filterMatchMode="contains" 
	        			id="responsibility" >
	        		<h:outputText value="#{aWrapper.user.fullName}" />
		        </p:column>
		    </p:dataTable>
		</h:form>
	</h:body>
</f:view>